﻿using System.IO;

namespace Facade.PageMaker
{
    class HtmlWriter
    {
        private StreamWriter writer;

        public HtmlWriter(StreamWriter writer)
        {
            this.writer = writer;
        }

        public void Title(string title)
        {
            writer.Write("<html>");
            writer.Write("<head>");
            writer.Write("<title>" + title + "</title>");
            writer.Write("</head>");
            writer.WriteLine("<body>");
            writer.WriteLine("<h1>" + title + "</h1>");
        }

        public void Paragraph(string msg)
        {
            writer.WriteLine("<p>" + msg + "</p>");
        }

        public void Link(string href, string caption)
        {
            Paragraph("<a href=\"" + href + "\">" + caption + "</a>");
        }

        public void MailTo(string mailAddress, string userName)
        {
            Link("mailto:" + mailAddress, userName);
        }

        public void Close()
        {
            writer.Write("</body>");
            writer.WriteLine("</html>");
            writer.Close();
        }

    }
}
